<include file="Public:header" />
<script type="text/javascript" src="__PUBLIC__/js/PCASClass.js" ></script>
<script src="__PUBLIC__/resume_selector/common.21a64352.js"></script>
<link rel="stylesheet" href="__PUBLIC__/resume_selector/common.41f94c00.css">
<link rel="stylesheet" href="__PUBLIC__/resume_selector/resume.search.12eb3a9b.css">
<style type="text/css">
	.add_title{
		padding-bottom:10px;
		height: 60px;
		margin-bottom:15px;
	}
	.add_title>span{
		border-bottom: 2px solid #1ab394;
		font-size: 24px;
	}
	.add_body >div >.full-height-scroll{
		border-right:1px dotted #ccc
	}
	.add_body_title{
		margin:20px auto 20px auto;
		padding-left: 25px;
	}
	.add_body_form{
		padding-left: 38px;
	}
	.add_body_form>form>.form-group{
		margin-bottom: 25px;
	}
	body{overflow-y:hidden;}
	.form-control{
		float:left;
	}
	.checkbox{float:left;}
</style>
<script>
    $(function(){
        $(".add_body").height(window.innerHeight-$("#add_body").offset().top-$("#tfoot_div").height()-40);
        $(window).resize(function(){
            $(".add_body").height(window.innerHeight-$("#add_body").offset().top-$("#tfoot_div").height()-40);
        })
    })
</script>
<div class="wrapper wrapper-content animated fadeIn">
	<form class="form-horizontal" id="form" role="form" action="{:U('customer/edit', 'id='.$customer['customer_id'])}" method="post">
		<input type="hidden" name="p" value="{$p}">
		<input type="hidden" name="customer_id" id="customer_id" value="{$customer['customer_id']}">
		<div class="ibox-content add_body" id="add_body" >
			<div class="row">
				<div class="col-md-6 add_body" style="padding-right: 0px;">
					<div class="full-height-scroll">
						<div class="row" >
						<div class="col-md-12 add_body_title">
							<div class="all-inline">
								<span class="sq-tag"></span>
								<div class="text-tag">
									<span>基础信息</span>
								</div>
							</div>
						</div>
						<div class="col-md-11 add_body_form">
							<volist name="field_list['main']" id="vo" key="key">
								<if condition="$vo['field'] neq 'customer_owner_id'">
									<div class="form-group">
										<label class="col-md-4 control-label">{$vo.name}：</label>
										<if condition="$vo['form_type'] == 'textarea'">
											<if condition = "$vo['tip_start'] eq 1">
												<div class="col-md-6">
													{$vo.html}
												</div>
												<div class="col-md-2"><span style="color: red;line-height: 32px;margin-left: 10px;">*</span></div>
												<else/>
												<div class="col-md-8">
													{$vo.html}
												</div>
											</if>
											<elseif condition="$vo['form_type'] == 'address' || $vo['form_type'] == 'box'"/>
											<if condition="$vo['field'] == 'grade'">
												<div class="col-md-8">
													<input type="hidden" id="star" name="grade" value="{$customer['grade']}">
													<div class="all-star" style="font-size: 18px;padding-top:3px;color:#D0D0D0;">
														<i class="fa fa-star">&nbsp;&nbsp;</i><i class="fa fa-star">&nbsp;&nbsp;</i><i class="fa fa-star">&nbsp;&nbsp;</i><i class="fa fa-star">&nbsp;&nbsp;</i><i class="fa fa-star">&nbsp;&nbsp;</i>
													</div>
												</div>
												<else/>
												<if condition = "$vo['tip_start'] eq 1">
													<div class="col-md-6">
														{$vo.html}
													</div>
													<div class="col-md-2"><span style="color: red;line-height: 32px;margin-left: 10px;">*</span></div>
													<else/>
													<div class="col-md-8">
														{$vo.html}
													</div>
												</if>
											</if>
											<elseif condition="$vo['field'] == 'name'"/>
											<div class="col-md-6">
												<input class="form-control required" name="name" onkeyup="checkinfo(name)" value="{$customer['name']}" type="text"/>
											</div>
											<if condition = "$vo['tip_start'] eq 1">
												<div class="col-md-2"><span style="color: red;line-height: 32px;margin-left: 10px;">*</span></div>
												<else/>
												<div class="col-md-2"></div>
											</if>
											<else/>
											<div class="col-md-6">
												{$vo.html}
											</div>
											<if condition = "$vo['tip_start'] eq 1">
												<div class="col-md-2"><span style="color: red;line-height: 32px;margin-left: 10px;">*</span></div>
												<else/>
												<div class="col-md-2"></div>
											</if>
										</if>
									</div>
								</if>
							</volist>
                            <div class="form-group">
                                <label class="col-md-4 control-label">维护人：</label>
                                <div class="col-md-6">
                                    <!--<input type="hidden" name="customer_owner_id" id="user_id" value="{$vo.customer_id}" />-->
                                    <input class="form-control required" aria-required="true" readonly="readonly"  type="text" name="customer_owner_name" id="user_name" value="{$customer_owner_name}" readonly="true" style="cursor:pointer;" />
                                </div>
                                <div class="col-md-2"><span style="color:red;line-height: 32px;margin-left: 10px;">*</span></div>
                            </div>
						</div>
						<div class="col-md-12 add_body_title">
							<div class="all-inline">
								<span class="sq-tag"></span>
								<div class="text-tag">
									<span>附加信息</span>
								</div>
							</div>
						</div>
						<div class="col-md-11 add_body_form">
							<volist name="field_list['data']" id="vo" key="key">
								<div class="form-group">
									<label class="col-md-4 control-label">{$vo.name}：</label>
									<if condition="$vo['form_type'] == 'address' || $vo['form_type'] == 'box'">
										<if condition = "$vo['tip_start'] eq 1">
											<div class="col-md-6">
												{$vo.html}
											</div>
											<div class="col-md-2"><span style="color: red;line-height: 32px;margin-left: 10px;">*</span></div>
											<else/>
											<div class="col-md-8">
												{$vo.html}
											</div>
										</if>
										<else/>
										<div class="col-md-6">
											{$vo.html}
										</div>
										<if condition = "$vo['tip_start'] eq 1">
											<div class="col-md-2"><span style="color: red;line-height: 32px;margin-left: 10px;">*</span></div>
											<else/>
											<div class="col-md-2"></div>
										</if>
									</if>
								</div>
							</volist>
						</div>
						<div class="col-md-1 pull-right">
							<!-- <div style="height: 100%; border-right: 1px dashed gray;">&nbsp;sadf</div> -->
						</div>
					</div>
					</div>
				</div>
				<div class="col-md-6 add_body" style="padding-left: 0px;">
					<div class="full-height-scroll">
						<div class="col-md-12 add_body_title">
							<div class="all-inline">
								<span class="sq-tag"></span>
								<div class="text-tag">
									<span>客户联系人</span>
								</div>
							</div>
						</div>
						<div class="col-md-10 add_body_form">
							<!--contacts_field_list['main']-->
							<volist name="contacts_field_list['mainn']" id="vo" key="key">
								<if condition = "$vo['form_type'] neq 'customer'">
									<div class="form-group">
										<label class="col-md-4 control-label">{$vo.name}：</label>
										<if condition="$vo['form_type'] == 'textarea'">
											<div class="col-md-8">
												<textarea class="form-control" rows="5"></textarea>
											</div>
											<elseif condition="$vo['form_type'] == 'address'"/>
											<div class="col-md-8">
												{$vo.html}
											</div>
											<elseif condition="$vo['form_type'] == 'box'"/>
											<div class="col-md-6">
												{$vo.html}
											</div>
											<div class="col-md-2"></div>
											<else/>
											<div class="col-md-6">
												{$vo.html}
											</div>
											<div class="col-md-2"></div>
										</if>
									</div>
								</if>
							</volist>
							<!--  直接写表单 3/20  -->
							<div class="form-group">
								<label class="col-md-4 control-label">重要程度：</label>
								<div class="col-md-6">
									<select class="form-control " id="con_contacts[crm_dbxxve]" name="con_contacts[crm_dbxxve]">
										<option value=''>--请选择--</option>
										<option value='非常重要' <if condition="$contacts[crm_dbxxve] eq '非常重要'">selected='selected'</if>>非常重要</option>
										<option value='重要' <if condition="$contacts[crm_dbxxve] eq '重要'">selected='selected'</if> >重要</option>
										<option value='一般'<if condition="$contacts[crm_dbxxve] eq '一般'">selected='selected'</if> >一般</option>
										<option value='较弱' <if condition="$ontacts[crm_dbxxve] eq '较弱'">selected='selected'</if> >较弱</option>
										<option value='离职' <if condition="$contacts[crm_dbxxve] eq '离职'">selected='selected'</if> >离职</option>
									</select>
									<span id="con_contacts[crm_dbxxve]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2"></div>
							</div><div class="form-group">
								<label class="col-md-4 control-label">姓名：</label>
								<div class="col-md-6">
									<input class="form-control " data-selector="con_name" type="text" id="con_name" name="con_contacts[name]"  value="{$contacts[name]}" placeholder="" />
									<span id="con_contacts[name]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2 ftw ftww all"></div>
								</div>
								<div class="form-group">
								<label class="col-md-4 control-label">职位：</label>
								<div class="col-md-6">
									<input class="form-control "  type="text" id="con_post" data-selector="con_post" name="con_contacts[post]"  value="{$contacts[post]}" placeholder="" />
									<span id="con_contacts[post]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2 ftww all"></div>
								</div>
								<div class="form-group">
								<label class="col-md-4 control-label">手机：</label>
								<div class="col-md-6">
									<input class="form-control " data-selector="con_telphone" type="mobile" id="con_telphone" name="con_contacts[telephone]"  value="{$contacts[telephone]}" />
									<span id="con_contacts[telephone]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2 ftw ftww all"></div>
								</div>
								<div class="form-group">
									<label class="col-md-4 control-label">座机：</label>
									<div class="col-md-6">
										<!--<input class="form-control " data-selector="con_phone" type="" id="con_phone" name="con_contacts[phone]"  value="{$contacts[phone]}" />
										<span id="con_contacts[phone]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>-->
                                        <input class="form-control "  type="text" data-selector="con_crm_ljgmqr" id="con_crm_ljgmqr" name="con_contacts[crm_ljgmqr]"  value="{$contacts[crm_ljgmqr]}" placeholder="" />
                                        <span id="con_contacts[crm_ljgmqr]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>         </div>
									<div class="col-md-2 ftw ftww all"></div>
								</div>
								<div class="form-group">
								<label class="col-md-4 control-label">QQ：</label>
								<div class="col-md-6">
									<input class="form-control " data-selector="con_qq_no"  type="text" id="con_qq_no" name="con_contacts[qq_no]"  value="{$contacts[qq_no]}" placeholder="" />
									<span id="con_contacts[qq_no]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2"></div>
								</div>
								<div class="form-group">
								<label class="col-md-4 control-label">性别：</label>
								<div class="col-md-6">
									<select class="form-control " data-selector="con_sex" id="con_sex" name="con_contacts[crm_zswstr]">
										<option value=''>--请选择--</option>
										<option value='男' <if condition="$contacts[crm_zswstr] eq '男'">selected='selected'</if> >男</option>
										<option value='女' <if condition="$contacts[crm_zswstr] eq '女'">selected='selected'</if> >女</option></select>
									<span id="con_contacts[crm_zswstr]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2 ftww all te"></div>
								</div>
								<div class="form-group">
								<label class="col-md-4 control-label">邮箱：</label>
								<div class="col-md-6">
									<input class="form-control " data-selector="con_email" type="email" id="con_email" name="con_contacts[email]"  value="{$contacts[email]}" />
									<span id="con_contacts[email]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2 ftww all"></div>
								</div>
							<div class="form-group">
								<label class="col-md-4 control-label">地址：</label>
								<div class="col-md-8">
									<script type="text/javascript">
                                        $(function(){
                                            new PCAS("con_contacts[contacts_address]['state']","con_contacts[contacts_address]['city']","con_contacts[contacts_address]['area']","{$contacts['state']}","{$contacts['city']}","{$contacts['area']}");
                                        });
									</script><select class="form-control " input_type="address" name="con_contacts[contacts_address]['state']" style="width:32%;float:left;" ></select>
									<select class="form-control " input_type="address" name="con_contacts[contacts_address]['city']" style="width:32%;float:left;margin-left:1%;"></select>
									<select class="form-control " input_type="address" name="con_contacts[contacts_address]['area']" style="width:32%;float:left;margin-left:1%;"></select>
									<input class="form-control" input_type="address" type="text" name="con_contacts[contacts_address]['street']" placeholder="街道信息" class="input-large" value="{$contacts['street']}" style="float:left;margin-top:5px;">											</div>
							</div>

							<div class="form-group">
								<label class="col-md-4 control-label">微信：</label>
								<div class="col-md-6">
									<input class="form-control "  type="text" data-selector="con_wetchat" id="con_wetchat" name="con_contacts[wetchat]"  value="{$contacts[wetchat]}" placeholder="" />
									<span id="con_contacts[wetchat]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2 "></div>
							</div>
							<div class="form-group">
								<label class="col-md-4 control-label">邮编：</label>
								<div class="col-md-6">
									<input class="form-control "  type="text" id="con_contacts[zip_code]" name="con_contacts[zip_code]"  value="{$contacts[zip_code]}" placeholder="" />
									<span id="con_contacts[zip_code]Tip" style="float: left;line-height: 32px;margin-left: 5%;color:red;"></span>											</div>
								<div class="col-md-2"></div>
							</div><div class="form-group">
							<label class="col-md-4 control-label">备注：</label>
							<div class="col-md-8">
								<textarea class="form-control" name="con_contacts[description]" rows="5">{$contacts[description]}</textarea>
							</div>
						</div>
						</div>
						<if condition = "$contacts_field_list['data']">
							<div class="col-md-12 add_body_title">
								<div classs="all-inline">
									<span class="sq-tag"></span>
									<div class="text-tag">
										<span>附加信息</span>
									</div>
								</div>
							</div>
						</if>
						<div class="col-md-10 add_body_form">
							<volist name="contacts_field_list['data']" id="vo" key="key">
								<div class="form-group">
									<label class="col-md-4 control-label">{$vo.name}：</label>
									<if condition="$vo['form_type'] == 'address' || $vo['form_type'] == 'box' || $vo['form_type'] == 'textarea'">
										<div class="col-md-8">
											{$vo.html}
										</div>
										<else/>
										<div class="col-md-6">
											{$vo.html}
										</div>
										<div class="col-md-2"></div>
									</if>
								</div>
							</volist>
						</div>
						<div class="col-md-2 pull-right">
							<!-- <div style="height: 100%; border-right: 1px dashed gray;">&nbsp;sadf</div> -->
						</div>
					</div>
				</div>
			</div>
		</div>
		<div id="tfoot_div" class="clearfix" style="text-align:center">
			<div class="clearfix" id="tfoot_page">
				<div class="ibox-content" style="border-top: none;">
					<div class="col-sm-offset-2" style="margin-left:0px;">
						<button type="submit" id="save_submit" class="btn btn-primary">保存</button>
						<input class="btn btn-default" type="button" onclick="javascript:history.go(-1)" value="{:L('RETURN')}"/>
					</div>
				</div>
			</div>
		</div>

	</form>
</div>
<script>
    var customer_status = $('#customer_status').val();
    if(customer_status == '已成交客户'){
        $('#customer_status').attr('disabled',true);
    }
    //验证重复项
    function checkinfo(param){
        var field_value = $('#'+param).val();
        var customer_id = $('#customer_id').val();
        if(field_value){
            $.post('{:U("customer/checkinfo")}',
                {
                    field_value:field_value,
                    field_name:param,
                    customer_id:customer_id,
                },
                function(data){
                    if(data.status == 1){
                        $('#'+param+'-error').remove('');
                        $('#'+param).after('<label id="'+param+'-error" class="error" for="source"><i class="fa fa-times-circle"></i></label>');
                        $('#'+param+'-error').html('<i class="fa fa-times-circle"></i>'+data.data);
                    }else{
                        $('#'+param+'-error').remove('');
                    }
                },
                'json');
        }
    }

    //客户来源 变换时
    function outline_change(obj){
        if( (obj.value.search('猎聘') != -1) || (obj.value.search('猎萝卜') != -1)){
            $('.all').html('');
            $('.ftw').html('<span style="color: red;line-height: 32px;margin-left: 10px;">*</span>');
        }else if(obj.value.search('线下')!=-1){
            $('.all').html('');
            $('.ftww').html('<span style="color: red;line-height: 32px;margin-left: 10px;">*</span>');
		}else {
            $('.all').html('');
        };
    }

    $(document).ready(function(){
		setTimeout(outline_change,500,document.querySelector('#origin'))
        /*form表单验证*/
        var ori = $("#origin").val();

        if(ori == '面试快' || ori == '入职快' ||ori == '专业猎头'  ){
            $('.ftw').html('<span style="color: red;line-height: 32px;margin-left: 10px;">*</span>');
        }else {
            $('.ftw').html('');
        };
        $("#form").validate({
            submitHandler:function(form){
                var origin = $('#origin option:selected').val();//选中的值
                // $('#save_submit').click(function(){
                //     $('#save_submit').prop('disabled',true);
                // });

                var industry = $("input[name=industry]").val();
                var area = $("#city_area").val();
                if($('.ftw').html() != '') flag = 1;
                if($('.te').html() != '') flag = 2;
                var introduce = $('#introduce').val();
                var name = $('#con_name').val();
                var tel = $('#con_telphone').val();
                var phone = $('#con_crm_ljgmqr').val();
                var qq = $('#con_qq_no').val();
                var weixin = $('#con_wetchat').val();
                var dqs = $("#wantdqs").val();
                var pos = $('#con_post').val();
                var sex= $('#con_sex').val();
                var email = $('#con_email').val();
                if(dqs=="" || dqs==null){
                    alert_crm("请填写所在城市信息！");
                    return;
                }
                if(!industry || industry == null){
                    alert_crm("请填写所属行业！");
                    return;
                }
                if(!introduce || introduce == null){
                    alert_crm("请填写公司简介！");
                    return;
                }
                if(!area || area == null){
                    alert_crm("请填写公司地址！");
                    return;
                }
                if(flag == 1){

                    if(name == '' || name == null){
                        alert_crm("请填写姓名！");
                        $("input[data-selector=con_name]").css("border","1px dotted #cc5965");
                        return;
                    }
                    if( (tel == '' || tel == null) && (phone =='' || phone == null) ){
                        alert_crm("请填写手机或者座机号 ！");
                        $("input[data-selector=con_telphone]").css("border","1px dotted #cc5965");
                        $("input[data-selector=con_crm_ljgmqr]").css("border","1px dotted #cc5965");
                        return;
                    }
                    // if((qq == '' || qq == null) && (weixin == '' || weixin == null)){
                    //     alert_crm("请填写qq或者微信！");
                    //     $("input[data-selector=con_qq_no]").css("border","1px dotted #cc5965");
                    //     $("input[data-selector=con_wetchat]").css("border","1px dotted #cc5965");
                    //     return;
                    // }
                    // if(weixin == '' || weixin == null){
                    //     alert_crm("请填写微信！");
                    //     $("input[data-selector=con_wetchat]").css("border","1px dotted #cc5965");
                    //     return;
                    // }
                    form.submit();
				}
				else if(flag == 2){
                    if(name == '' || name == null){
                        alert_crm("请填写姓名！");
                        $("input[data-selector=con_name]").css("border","1px dotted #cc5965");
                        return;
                    }
                    if(pos == ''  ||pos == null){
                        alert_crm("请填写职位！");
                        $("input[data-selector=con_post]").css("border","1px dotted #cc5965");
                        return;
                    }
                    if( (tel == '' || tel == null) && ( phone == ''|| phone==null)){
                        alert_crm("请填写手机或者座机！");
                        $("input[data-selector=con_telphone]").css("border","1px dotted #cc5965");
                        $("input[data-selector=con_crm_ljgmqr]").css("border","1px dotted #cc5965");
                        return;
                    }
                    // if((qq == '' || qq == null) && (weixin == '' || weixin == null)){
                    //     alert_crm("请填写qq或者微信！");
                    //     $("input[data-selector=con_qq_no]").css("border","1px dotted #cc5965");
                    //     $("input[data-selector=con_wetchat]").css("border","1px dotted #cc5965");
                    //     return;
                    // }
                    if(sex == ''  ||sex == null){
                        alert_crm("请填写性别！");
                        $("input[data-selector=con_sex]").css("border","1px dotted #cc5965");
                        return;
                    }
                    if(email == ''  ||email == null){
                        alert_crm("请填写邮箱！");
                        $("input[data-selector=con_email]").css("border","1px dotted #cc5965");
                        return;
                    }
                    form.submit();
				}
                else{
                    form.submit();
                }
            }
        });
    });
    var star = $('#star').val();
    if(star == '' || star == null){
        $('.fa-star').removeClass("star-orange");
    }else{
        $('.fa-star').removeClass("star-orange");
        $('.fa-star:lt('+star+')').addClass("star-orange");
    }
    /*星星特效*/
    $('.fa-star').mousemove(function(){
        $(this).addClass("star-orange");
        $(this).prevAll().addClass("star-orange");
        $(this).nextAll().removeClass("star-orange");
    });
    $('.fa-star').mouseout(function(){
        var star = $('#star').val();
        if(star == '' || star == null){
            $('.fa-star').removeClass("star-orange");
        }else{
            $('.fa-star').removeClass("star-orange");
            $('.fa-star:lt('+star+')').addClass("star-orange");
        }
    });
    $('.fa-star').click(function(){
        var num = $(this).index() + 1;
        $('#star').val(num);

    });
</script>
<script src="__PUBLIC__/resume_selector/resume.search.910ebde0.js "></script>
